%% @author Rain
%% @doc 消息分配模块


-module(msg_distrib).

%% ====================================================================
%% API functions
%% ====================================================================
-export([msg_to_mod/3]).
-include("proto.hrl").
-include("config.hrl").

%% ====================================================================
%% Internal functions
%% ====================================================================

%% 将消息分配到对应模块。 -> 后续可通过配置读取，方便查询协议
msg_to_mod(?PROTO_MSG_LOGIN = MsgId, Msg, Player) ->
	account_gate:handle_msg(MsgId, Msg, Player);

msg_to_mod(MsgId, Msg, Player) ->
	case cfg_proto:get(MsgId) of
		#cfg_proto{msg_mod = MsgMod} ->
			MsgMod:handle_msg(MsgId, Msg, Player);
		_ ->
			io:format("MsgId：~p Undef MsgMod", [MsgId]),
			{noreply, Player}
	end.
			